<template>
  <div>
    <Input v-model:value="value">
      <template #suffix> 元 </template>
    </Input>
  </div>
</template>
<script setup>
import { defineEmits, ref, watch } from "vue";
import { Input, Form } from "ant-design-vue";
const formItemContext = Form.useInjectFormItemContext();
const emits = defineEmits(["update:modelValue", "change", "blur"]);
const props = defineProps({
  componentSchema: {
    default: () => ({}),
    type: Object,
  },
  modelValue: {
    default: () => "",
    type: String,
  },
});
const value = ref("");
// 读卡完成后

watch(value, (e) => {
  emits("update:modelValue", e);

  // 触发校验的change事件
  formItemContext.onFieldChange(e);
});

watch(
  () => props.modelValue,
  (e) => {
    if (e && e.length > 0) {
      value.value = e;
    }
  },
  { immediate: true }
);
</script>
